package com.shop.cloud.mall.admin.controller;

import cn.hutool.json.JSONObject;
import com.shop.cloud.common.im.entity.LoginReq;
import com.shop.cloud.common.im.entity.RegisterReq;
import com.shop.cloud.common.im.util.IMUtils;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @date 2018/11/14
 * <p>
 * IM控制类
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/im")
@Tag(description = "im", name = "im控制类")
public class IMController {
	private final IMUtils iMUtils;

	/**
	 * 登录
	 * @return
	 */
	@Operation(summary = "登录")
	@PostMapping("/login")
	public JSONObject login(@RequestBody LoginReq loginReq) {
		return iMUtils.login(loginReq);
	}

	/**
	 * 注册
	 * @return
	 */
	@Operation(summary = "注册")
	@PostMapping("/register")
	public JSONObject register(@RequestBody RegisterReq registerReq) {
		return iMUtils.register(registerReq);
	}
}
